using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;

namespace LenninSoftware.FormEditor
{
    public class AdapterFactory: IAdapterFactory
    {

        public virtual BaseControlAdapter Create(FieldInfo field, int localeID, SPWeb web)
        {

            if (field.InternalName == "ServerUrl")
                return new Adapters.EditDocument();

            switch (field.FieldType)
            {
                case SPFieldType.DateTime:

                    return new LenninSoftware.FormEditor.Adapters.DateTime(localeID);

                case SPFieldType.Text:

                    return new LenninSoftware.FormEditor.Adapters.Text();

                case SPFieldType.Note:
                    return new Adapters.Note();

                case SPFieldType.Number:
                    return new Adapters.Number();
                   
                case SPFieldType.Choice:
                    return new Adapters.Choice();


                case SPFieldType.User:
                    return new Adapters.User(web);

                case SPFieldType.Lookup:
                    return new Adapters.Lookup(web);

                case SPFieldType.Computed:
                    return new Adapters.Computed();

                case SPFieldType.Boolean:
                    return new Adapters.Boolean();

                default:

                    return new Adapters.Unknown();
                
            }

        }
    }
}
